#include<stdio.h>
#include<stdlib.h>


//全局变量
int g_uninit_val;//未初始化的
int g_init_val = 100;//初始化过的


int main(int argc, char* argv[], char* env[]){
  
  //栈区
  int a = 1;
  int b = 2;
  int c = 3;

  //堆区
  int* p1 = (int*)malloc(2 * sizeof(int));
  int* p2 = (int*)malloc(3 * sizeof(int));
  int* p3 = (int*)malloc(4 * sizeof(int));

  //常量区
  const char* str = "hello world";
  const int ca = 50;
  
  //静态变量
  static double x = 3.5;

  printf("code addr:%p\n", main);
  printf("\n");

  printf("init global_val : %p\n", &g_init_val);
  printf("uninit global_val : %p\n", &g_uninit_val);
  printf("\n");

  printf("stack addr:\n");
  printf("a : %p\n", &a);
  printf("b : %p\n", &b);
  printf("c : %p\n", &c);
  printf("\n");


  printf("heap addr:\n");
  printf("p1 : %p\n", p1);
  printf("p2 : %p\n", p2);
  printf("p3 : %p\n", p3);
  printf("\n");

  
  printf("static addr : %p\n", &x);
  printf("\n");

  printf("const val:\n");
  printf("str : %p\n", str);
  printf("ca : %p\n", &ca);
  printf("\n");

  printf("CMDLINE Argments:\n");
  for(int i = 0; i < argc; ++i){
    printf("argv[%d]->%s : %p\n",i , argv[i], &argv[i]);
  }
  printf("\n");

  for(int i = 0; env[i]; ++i){
    printf("env[%d]->%s : %p\n",i , env[i], &env[i]);
  }
  printf("\n");
  return 0;
}
